package com.demo.webflux.jpaadapter;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

/**普通jpa
 * jpa还没有响应式，所以可以通过响应式api转换
 * @author zhangsulei
 *
 */
@Repository
public interface BookJpaRepository extends CrudRepository<Book, Integer> {

	Iterable<Book> findByIdBetween(int lower, int upper); // 基于命名约定生成查询

	@Query("select b from Book b where length(b.title) = (select min(length(b2.title)) from Book b2)") // 使用自定义sql
	Iterable<Book> findShortestTitle();

}
